package com.ygo.feihua.adapter;
import android.content.*;
import android.widget.*;
import java.util.*;
import android.view.*;
import com.ygo.feihua.*;
import com.bumptech.glide.*;

public class ImageSelectAdapter extends BaseAdapter
{

	private List<String> data;
	private ViewHolder vh;
	private Context context;

	public ImageSelectAdapter(Context context,List<String> data){
		this.context=context;
		this.data=data;
	}

	public void closeImage()
	{
		data.clear();
		data.add("");
		// TODO: Implement this method
	}

	
	public void removeImage(int p3)
	{
		data.remove(p3);
		// TODO: Implement this method
	}

	public void sx()
	{
		notifyDataSetChanged();
		// TODO: Implement this method
	}

	public void addImage(String s)
	{
		data.add(s);
		// TODO: Implement this method
	}
	
	
	
	
	@Override
	public int getCount()
	{
		// TODO: Implement this method
		return data.size();
	}

	@Override
	public Object getItem(int p1)
	{
		// TODO: Implement this method
		return data.get(p1);
	}

	@Override
	public long getItemId(int p1)
	{
		// TODO: Implement this method
		return p1;
	}

	@Override
	public View getView(int position, View p2, ViewGroup p3)
	{
		if(p2==null){
			vh=new ViewHolder();
			p2=LayoutInflater.from(context).inflate(R.layout.item_image,null);
			vh.image=(ImageView) p2.findViewById(R.id.ii_image);
			p2.setTag(vh);
			
		}else{
			vh=(ImageSelectAdapter.ViewHolder) p2.getTag();
		}
		String path=data.get(position);
		if(position==0){
			vh.image.setImageResource(R.drawable.sc_yl);
		}else{
		if(path!=null&&!path.equals("")){
			Glide.with(context).load(path).into(vh.image);
		}
		}
		
		// TODO: Implement this method
		return p2;
	}
	
	
	class ViewHolder{
		ImageView image;
	}
	
}
